use std::{fs::File, io::Write, path::PathBuf};

pub fn is_hidden_file(path: &PathBuf) -> bool {
    path.file_name()
        .and_then(|name| name.to_str())
        .map(|name| name.starts_with('.'))
        .unwrap_or(false)
}

pub fn is_not_hidden_file(path: &PathBuf) -> bool {
    return !is_hidden_file(path);
}

pub fn append_line_to_file(output_file_path: &PathBuf, lines: &Vec<String>) {
    let mut file = File::options()
        .append(true)
        .create(true)
        .open(output_file_path)
        .expect("not create file ");
    for line in lines {
        file.write_all(line.as_bytes()).unwrap();
        file.write_all(b"\n").unwrap();
    }
}
